import { getListApi as channelApi } from "@/api/configCenter/outBoundAgent";
import { getTreeChannelApi } from "@/api/configCenter/warehouseEntryChannel";
import { getAllSelectListApi } from "@/api/insuranceCompany";
import { reactive } from "vue";
import { TreeSelect } from "ant-design-vue";
const SHOW_CHILD = TreeSelect.SHOW_CHILD;
export const searchItemList: Array<SuperSearch.SearchItem> = [
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "保险公司",
    keyName: "idList",
    optionsRequest: getAllSelectListApi,
    optReqParams: {},
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data || [];
      }
    },
    attrs: {
      mode: "multiple"
    },
    optConfig: {
      label: "name",
      value: "id"
    },
    options: []
  }),

  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "出仓渠道限制",
    keyName: "agentIdList",
    optionsRequest: channelApi,
    optReqParams: { pageNum: 1, pageSize: 9999, total: 9 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data.records || [];
      }
    },
    attrs: {
      mode: "multiple"
    },
    optConfig: {
      label: "name",
      value: "id"
    },
    options: []
  }),
  {
    type: "datetimerange",
    label: "创建时间",
    keyName: "createTimeList"
  },
  reactive<SuperSearch.SearchItem>({
    type: "cascader",
    label: "渠道",
    keyName: "channelIdList",
    optionsRequest: getTreeChannelApi,
    optReqParams: {},
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data || [];
      }
    },
    optConfig: {
      label: "label",
      value: "value",
      children: "children"
    },
    attrs: {
      multiple: true,
      showCheckedStrategy: SHOW_CHILD
    },
    options: []
  }),
  {
    type: "select",
    label: "单位",
    keyName: "unitList",
    // lookupCode: "UNIT",
    optConfig: {
      label: "name",
      value: "name"
    },
    attrs: {
      mode: "multiple"
    },
    options: [
      {
        name: "票",
        code: "1"
      },
      {
        name: "件",
        code: "2"
      },
      {
        name: "KG",
        code: "3"
      }
    ]
  }
];

// 列表
export const tableColumn: Array<SuperTable.TableCoulmnItem | SuperTable.NestTableColumnItem> = [
  {
    type: "checkbox",
    field: "checkbox",
    minWidth: "50",
    fixed: "left"
  },
  {
    field: "name",
    title: "保险公司",
    minWidth: "90"
  },
  {
    field: "agentName",
    title: "出仓代理限制",
    minWidth: "120"
  },
  {
    field: "goodLimit",
    title: "货值限制",
    minWidth: "120"
  },
  {
    field: "updateName",
    title: "修改人",
    minWidth: "120"
  },
  {
    field: "status",
    title: "状态",
    minWidth: "120",
    renderSlot: "status"
  },
  {
    field: "orderEnd",
    title: "截单时间",
    minWidth: "120"
  },
  {
    field: "updateTime",
    title: "修改时间",
    minWidth: "120",
    formatter: "formatDate"
  },
  {
    field: "action",
    title: "操作",
    minWidth: "180",
    renderSlot: "action"
  }
];
